package com.egao.common.module.counsel.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.egao.common.core.exception.BusinessException;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Arrays;

/**
 * 咨询类型枚举
 * @author warmwind
 * @since 2024-09-25 下午12:21
 */
public enum CounselTypeEnum {
    /** 个体咨询 */
    GTFD(1, "个体咨询"),
    /** 考研专题 */
    KYZT(2, "考研专题"),
    /** 考公专题 */
    KGZT(3, "考公专题"),
    /** 团体辅导 */
    TTFD(4, "团体辅导");

    @EnumValue
    private final Integer value;

    @JsonValue
    private final String label;

    public Integer getValue() {
        return value;
    }

    public String getLabel() {
        return label;
    }

    CounselTypeEnum(Integer value, String label) {
        this.value = value;
        this.label = label;
    }

    public static CounselTypeEnum getByValue(Integer value) {
        return Arrays.stream(CounselTypeEnum.values())
                .filter(item -> item.getValue().equals(value))
                .findFirst()
                .orElseThrow(() -> new BusinessException("枚举值不存在"));
    }

    public static CounselTypeEnum getByLabel(String label) {
        return Arrays.stream(CounselTypeEnum.values())
                .filter(item -> item.getLabel().equals(label))
                .findFirst()
                .orElseThrow(() -> new BusinessException("枚举标签不存在"));
    }
}
